home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 60 / IOPROG_60.ISO / soft / c++ / gsl-1.1.1-setup.exe / {app} / src / cblas / hypot.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-02  |  458 b   |  29 lines

  1. #include <math.h>
  2.  
  3. static double xhypot (const double x, const double y);
  4.  
  5. static double xhypot (const double x, const double y)
  6. {
  7.   double xabs = fabs(x) ;
  8.   double yabs = fabs(y) ;
  9.   double min, max;
  10.  
  11.   if (xabs < yabs) {
  12.     min = xabs ;
  13.     max = yabs ;
  14.   } else {
  15.     min = yabs ;
  16.     max = xabs ;
  17.   }
  18.  
  19.   if (min == 0) 
  20.     {
  21.       return max ;
  22.     }
  23.  
  24.   {
  25.     double u = min / max ;
  26.     return max * sqrt (1 + u * u) ;
  27.   }
  28. }
  29.